//
//  SelectTableViewCell.m
//  GC_OC
//
//  Created by 曾 on 2022/1/17.
//

#import "SelectTableViewCell.h"

@implementation SelectTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.nameLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightRegular];
    self.nameLabel.textAlignment = NSTextAlignmentLeft;
    self.selectionStyle= UITableViewCellSelectionStyleNone;
    self.tipsLabel.hidden = YES;
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(wid(20));
    }];

}

- (void)setContentInfo:(NSString *)contentInfo {
    _contentInfo = contentInfo;
    NSArray *infoArr = [self handleStringWithString:contentInfo];
    self.nameLabel.text = [infoArr firstObject];

    if (infoArr.count == 1) {
        self.tipsLabel.hidden = YES;
    }else {
        self.tipsLabel.hidden = NO;
        self.tipsLabel.text = infoArr[1];
    }
}

- (void)setIsSelected:(BOOL)isSelected {
    _isSelected = isSelected;
    if (isSelected) {
        self.nameLabel.textColor = RBG(46,119,250);
        self.tipsLabel.textColor = RBG(46,119,250);
        self.backgroundColor = RBG(224,244,254);
        self.nameLabel.font = fk_adjustBoldFont(18);
    }else {
        self.tipsLabel.textColor = [UIColor grayColor];
        self.nameLabel.textColor = [UIColor blackColor];
        self.backgroundColor = RBG(245,245,245);
        self.nameLabel.font = fk_adjustFont(18);
    }
}

//去除字符串中用括号括住的位置
- (NSArray *)handleStringWithString:(NSString *)str{
    NSString *string = [str stringByReplacingOccurrencesOfString:@"(" withString:@"|"];
    string = [string stringByReplacingOccurrencesOfString:@"（" withString:@"|"];
    string = [string stringByReplacingOccurrencesOfString:@")" withString:@"|"];
    string = [string stringByReplacingOccurrencesOfString:@"）" withString:@"|"];
    NSArray *infoArr = [string componentsSeparatedByString:@"|"];
    return infoArr;
}

@end
